*Do-file for James and Van Ryzin, JBPA 2019

*Drop low-quality respondents
encode term_0, generate(term_0n)
keep if term_0n==.

***********************************************
*Demographic profile
***********************************************
gen Q1_4C = Q1_4
recode Q1_4C (18/24=1)(25/44=2)(45/59=3)(60/74=4)(75/100=5)

tab Q1_3
tab Q1_4C
tab Q1_5
tab Q1_6
tab Q15_10
tab Q15_11

*******************************************
*RATIO BIAS EXPERIMENT
*******************************************'

gen Violentcrime=.
recode Violentcrime (.=1) if  Violentcrime_DO_Q7_1==1
recode Violentcrime (.=2) if  Violentcrime_DO_Q7_2==1
recode Violentcrime (.=3) if  Violentcrime_DO_Q7_3==1
recode Violentcrime (.=4) if  Violentcrime_DO_Q7_4==1
recode Violentcrime (.=5) if  Violentcrime_DO_Q7_5==1
recode Violentcrime (.=6) if  Violentcrime_DO_Q7_6==1
quietly tabulate Violentcrime, generate(Violentcrime_)

gen Infantmortality=.
recode Infantmortality (.=1) if  Infantmortality_DO_Q8_1==1
recode Infantmortality (.=2) if  Infantmortality_DO_Q8_2==1
recode Infantmortality (.=3) if  Infantmortality_DO_Q8_3==1
recode Infantmortality (.=4) if  Infantmortality_DO_Q8_4==1
recode Infantmortality (.=5) if  Infantmortality_DO_Q8_5==1
recode Infantmortality (.=6) if  Infantmortality_DO_Q8_6==1
quietly tabulate Infantmortality, generate(Infantmortality_)

alpha Q15_2 Q15_3 Q15_4 Q15_5, generate(Numeracy) item
alpha Q15_2 Q15_3 Q15_4 Q15_5, generate(Numeracy1) item std
gen Numeracy2 = Numeracy1
recode Numeracy2 (-3/0=0)(0/3=1)
sum Numeracy
sum Numeracy1
sum Numeracy2

gen Q7_8r = 8 - Q7_8
gen Q8_8r = 8 - Q8_8

egen zQ7_7_1 = std(Q7_7_1)
egen zQ7_8r = std(Q7_8r)
egen zQ8_7_1 = std(Q8_7_1)
egen zQ8_8r = std(Q8_8r)

*Analysis

oneway Q7_7_1 Violentcrime, tabulate
pwmean Q7_7_1, over(Violentcrime) mcompare(tukey) effects
cibar Q7_7_1, over1(Violentcrime) level(90)
oneway Q7_8r Violentcrime, tabulate
pwmean Q7_8r, over(Violentcrime) mcompare(tukey) effects
cibar Q7_8r, over1(Violentcrime) level(90)

oneway Q8_7_1 Infantmortality, tabulate
pwmean Q8_7_1, over(Infantmortality) mcompare(tukey) effects
cibar Q8_7_1, over1(Infantmortality) level(90)
oneway Q8_8r Infantmortality, tabulate
pwmean Q8_8r, over(Infantmortality) mcompare(tukey) effects
cibar Q8_8r, over1(Infantmortality) level(90)

*Regressions (with US gov reported ratio as the reference group)
reg Q7_7_1  Violentcrime_1 Violentcrime_2 Violentcrime_4 Violentcrime_5 Violentcrime_6, beta
reg Q7_8r  Violentcrime_1 Violentcrime_2 Violentcrime_4 Violentcrime_5 Violentcrime_6, beta
reg Q8_7_1 Infantmortality_1 Infantmortality_2 Infantmortality_4 Infantmortality_5 Infantmortality_6, beta
reg Q8_8r Infantmortality_1 Infantmortality_2 Infantmortality_4 Infantmortality_5 Infantmortality_6, beta

*Y-standardied regressions (with US gov reported ratio as the reference group)
reg zQ7_7_1  Violentcrime_1 Violentcrime_2 Violentcrime_4 Violentcrime_5 Violentcrime_6, beta
reg zQ7_8r  Violentcrime_1 Violentcrime_2 Violentcrime_4 Violentcrime_5 Violentcrime_6, beta
reg zQ8_7_1 Infantmortality_1 Infantmortality_2 Infantmortality_4 Infantmortality_5 Infantmortality_6, beta
reg zQ8_8r Infantmortality_1 Infantmortality_2 Infantmortality_4 Infantmortality_5 Infantmortality_6, beta

*ANCOVA and two-way ANOVA with numeracy
anova Q7_7_1 Violentcrime##c.Numeracy1
anova Q7_8r Violentcrime##c.Numeracy1
anova Q8_7_1 Infantmortality##c.Numeracy1
anova Q8_8r Infantmortality##c.Numeracy1

anova Q7_7_1 Violentcrime##Numeracy2
anova Q7_8r Violentcrime##Numeracy2
anova Q8_7_1 Infantmortality##Numeracy2
anova Q8_8r Infantmortality##Numeracy2
